class UsersController < ApplicationController
  def new

  end

  def create
    @user = User.new(params[:user])
    @user.save!
    self.current_user = @user
    redirect_to :controller => 'home', :action =>'myerrors'
    flash[:notice] = "Thanks for signing up!"
  rescue ActiveRecord::RecordInvalid
    redirect_to :controller => :home, :action => 'index', :register_email => @user.errors['email'],
                :register_password => @user.errors['password'], 
                :register_password_confirmation => @user.errors['password_confirmation'],
                :register => true
  end

  def activate
    self.current_user = User.find_by_activation_code(params[:activation_code])
    p self.current_user
    if logged_in? && !current_user.activated?
      current_user.activate
      flash[:notice] = "Signup complete!"
      return redirect_to(:controller => 'home', :action =>'setup_instructions')
    end
    redirect_back_or_default('/')
  end

  
end
